package com.xxx.gaoxi.common.service.facade.exception.handler;

import com.xxx.gaoxi.common.service.facade.entity.dto.RetDTO;
import com.xxx.gaoxi.common.service.facade.exception.BizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * Description
 * ...
 * DATE 2018/4/2.
 *
 * @author Mr. Chun.
 */
@ControllerAdvice("com.xxx.gaoxi")
public class ExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(ExceptionHandler.class);

    @org.springframework.web.bind.annotation.ExceptionHandler(value = BizException.class)
    @ResponseStatus(value = HttpStatus.BAD_REQUEST)
    @ResponseBody
    public RetDTO handlerBizException(BizException e) {
        logger.error(e.getMessage());
        return new RetDTO(HttpStatus.BAD_REQUEST.value(), "服务端服务异常");
    }

}
